#列表基本操作
alien_0 = {'color':'green', 'point':5}
print(alien_0)
alien_0['x_position'] = 0
alien_0['y_position'] = 25
print(alien_0)
print(f"The alien color is {alien_0['color']}.")
alien_0['color'] = 'yellow'
print(f"The alien color is {alien_0['color']}.")
del alien_0['point']
print(alien_0)
point_value = alien_0.get('point', 'No point value assigned')
print(point_value)
user_0 = {
    'username':'efermi',
    'first':'enrico',
    'last':'fermi',
}
for key, value in user_0.items():
    print(f"\nKey: {key}")
    print(f"Value: {value}")
for key in user_0.keys():
    print(key.title())
for value in set(user_0.values()):
    print(value.title())

#字典列表
alien_0 = {'color': 'green', 'point':5}
alien_1 = {'color': 'yellow', 'point':10}
alien_2 = {'color': 'red', 'point':15}
aliens = [alien_0, alien_1, alien_2]
for alien in aliens:
    print(alien)

#列表字典
favorite_languages = {
    'jen':['python', 'rust'],
    'sarah':['c'],
    'edward':['rust', 'go'],
    'phil':['python', 'haskell'],
}
for name, languages in favorite_languages.items():
    print(f"\n{name.title()}'s favorite languages are:")
    for language in languages:
        print(f"\t{language.title()}")

#字典嵌套
users = {
    'aeinstein':{
        'first':'albert',
        'last':'einstein',
        'location':'princeton'
    },
    'mcurie':{
        'first':'marie',
        'last':'curie',
        'location':'paris'       
    },
}
for username, user_info in users.items():
    print(f"\nUsername: {username}")
    full_name = f"{user_info['first']} {user_info['last']}"
    location = user_info['location']
    print(f"\tFull name: {full_name.title()}")
    print(f"\tlocation:{location.title()}")